<%--
  Created by IntelliJ IDEA.
  User: wyl
  Date: 2022-01-04
  Time: 16:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<div class="container">
    <div class="modal fade" id="savemy01Modal" >
        <div class="modal-dialog" style="width: 800px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">安全库存配置单</h4>
                </div>
                <div class="modal-body">
                    <form id=" " class="form form-horizontal">
                      <label>产品名称:</label>
                        <input type="text" id="saveproductName" style="border: none">
                        <label>产品编号:</label>
                        <input type="text" id="saveproductId" style="border: none"><br><br>
                        <label>库存下限数:</label>
                        <input type="text" name="saveminAmount" id="saveminAmount"  value="0" style="border-left-style: none;border-right-style: none;border-top-style: none">
                        <label>库存上限数:</label>
                        <input type="text" name="savemaxAmount" id="savemaxAmount" value="1000" style="border-left-style: none;border-right-style: none;border-top-style: none"><br><br>
                        <label>设置B/N或S/N:</label>
                            <select style="width: 120px"><option>额...</option><option>设置B/N</option><option>设置S/N</option></select>
                        <label>设计人 :</label>
                        <input type="search"  name="" id="1"><br><br>
                        <div class="row">
                            <table id="savetablea" border="1px">
                                <tr><td>库存编号</td><td>仓库名称</td><td>存储地址编号</td><td>存储地址名称</td><td>存储单元简称</td><td>最大存储量</td><td>存储单位</td></tr>

                            </table>
                        </div><br><br>
                        <label>登记人:</label>
                        <input type="text" name="saveregister"  id="saveregister" style="border-left-style: none;border-right-style: none;border-top-style: none">
                        <label>登记时间:</label>
                        <input type="text" name="saveregisterTime" id="saveregisterTime" style="border: none"><br><br>
                        <label>配置要求:</label>
                        <input type="text" name="saveconfig" id="saveconfig" value="恩黑" style="width: 600px;height: 80px;">

                       <%-- <div class="form-group">
                            <label for="productId" class="col-md-2 text-right control-label">产品编号：</label>
                            <div class="clo-md-4">
                                <input type="text" class="form-control" name="productId" id="productId">
                            </div>
                        </div>--%>
                        <div class="modal-footer">
                            <input type="button" class="btn btn-success" value="提交"  id="saveaddscell">
                            <input type="button" class="btn btn-warning" data-dismiss="modal" value="返回">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>



    <!--条件查询用 form -->
    <div id="toolbar">
        <form class="form form-inline">
            <div class="form-group">
                        <label>I&nbsp;级分类：</label><select id="saveFIRST_KIND_ID_01"  class="form-control "style="width: 200px">
                        <option value="">---请选择I级分类---</option>
                    </select>&nbsp;
                        <label >II&nbsp;级分类：</label><select id="saveFIRST_KIND_ID_02" class="form-control "style="width: 200px">
                        <option value="">---请选择II级分类---</option>
                    </select>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <label >III&nbsp;级分类：</label><select id="saveFIRST_KIND_ID_03" class="form-control "style="width: 200px">
                        <option value="">---请选择III级分类---</option>
                    </select>
               <%-- <input type="" id="firstKindId" class="form-control">--%>
                <%--<label for="thirdKindId" class="control-label">三菜单：</label>
                <input type="text" id="thirdKindId" class="form-control">--%>
            <input type="button" class="btn btn-success" value="查询" id="saveerbtnsearch">
            </div>
        </form>
    </div>
    <!-- 表格展示数据-->
    <table id="savedfilebl">

    </table>
</div>
<input type="hidden" id="saveid_secelluler">
<script>

    var params = {
        url: "${pageContext.request.contextPath}/querybyAlldfilewangyingliang.action",
        method: 'GET',                      //请求方式（*）
        toolbar: '#savetoolbar',              //工具按钮用哪个容器
        striped: true,                      //是否显示行间隔色
        cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true,                   //是否显示分页（*）
        sortable: true,                     //是否启用排序
        sortOrder: "asc",                   //排序方式
        sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1,                      //初始化加载第一页，默认第一页,并记录
        pageSize: 5,                     //每页的记录行数（*）
        pageList: [5, 10, 25, 50, 100],        //可供选择的每页的行数（*）
        search: false,                      //是否显示表格搜索
        strictSearch: true,
        showColumns: true,                  //是否显示所有的列（选择显示的列）
        showRefresh: true,                  //是否显示刷新按钮
        minimumCountColumns: 2,             //最少允许的列数
        clickToSelect: true,                //是否启用点击选中行
        height: 500,                      //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
        uniqueId: "id",                     //每一行的唯一标识，一般为主键列
        showToggle: true,                   //是否显示详细视图和列表视图的切换按钮
        cardView: false,                    //是否显示详细视图
        detailView: false,                  //是否显示父子表
        //传递额外的查询用的参数
        queryParams: function (params) {

            //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            var temp = {
                pagesize: params.limit,                         //页面大小
                pageno: (params.offset / params.limit) + 1,   //页码
                designCellTag:"K001-0",
                firstKindId:$("#saveFIRST_KIND_ID_01").val(),
                secondKindId:$("#saveFIRST_KIND_ID_02").val(),
                thirdKindId:$("#saveFIRST_KIND_ID_03").val()



            };
            return temp;
        },
        columns: [
            {
                title: "编号",
                field: "id"
            },

            {
                title: "产品编号",
                field: "productId"
            },
            {
                title: "产品名称",
                field: "productName"
            },

            {
                title: "产品I级分类名称",
                field: "firstKindName"
            },

            {
                title: "产品II级分类名称",
                field: "secondKindName"
            },

            {
                title: "产品III级分类名称",
                field: "thirdKindName"
            },
            {
              title: "档次级别",
                field: "productClass"
            },
            {
                title: "操作",
                field: "",
                formatter: function (value, row, index) {

                    return "<input type='button' onclick='openeditwin("+row.id+")'  value='定制' data-toggle='modal' data-target='#savemy01Modal' class='btn btn-warning'>";


                }

            }
        ]
    };

    $("#savedfilebl").bootstrapTable(params);
        $("#saveerbtnsearch").click(function () {
       $("#savedfilebl").bootstrapTable("refresh");
   })
    var rows;
    /*$("#btnsearch").click(fuznction () {
        $("#docutortbl").bootstrapTable("refresh");
    })*/
    function menushow001() {
        $.get("${pageContext.request.contextPath}/queryfifstkindname.action",function (data) {
            $("#saveFIRST_KIND_ID_01>option:gt(0)").remove()
            $(data).each(function (index, item) {
                var option = $("<option value="+item.firstKindId+">" + item.firstKindName + "</option>")
                $("#saveFIRST_KIND_ID_01").append(option)
            })
            $("#saveFIRST_KIND_ID_01").blur(function () {
                $("#saveFIRST_KIND_ID_02>option:gt(0)").remove()
               $("#saveFIRST_KIND_ID_03>option:gt(0)").remove()
                var fir=$("#saveFIRST_KIND_ID_01").val()
               menushow002()
            })
        },"json");
    }

    function menushow002() {
        $.get("${pageContext.request.contextPath}/queryfifstkindname.action",function (data) {
            $("#saveFIRST_KIND_ID_02>option:gt(0)").remove()
            $(data).each(function (index, item) {
                var option = $("<option value="+item.secondKindId+">" + item.secondKindName + "</option>")
                $("#saveFIRST_KIND_ID_02").append(option)
            })
            $("#saveFIRST_KIND_ID_02").blur(function () {
                $("#saveFIRST_KIND_ID_03>option:gt(0)").remove()
                var fir=$("#saveFIRST_KIND_ID_02").val()
               menushow003(fir)
            })
        },"json");
    }
    function menushow003() {
        $.get("${pageContext.request.contextPath}/queryfifstkindname.action",function (data) {
            $("#saveFIRST_KIND_ID_03>option:gt(0)").remove()
            $(data).each(function (index, item) {
                var option = $("<option value="+item.thirdKindId+">" + item.thirdKindName + "</option>")
                $("#saveFIRST_KIND_ID_03").append(option)

                var fir=$("#saveFIRST_KIND_ID_03").val();
            })
        },"json");


    }
    menushow001();

   function openeditwin(id) {
        $.get("${pageContext.request.contextPath}/queryDFileulbyid.action/"+id,
            function (data) {
            alert(data.id)
                $("#saveid_secelluler").val(data.id)
                $("#savetablea tr:gt(0)").remove();
               $("#saveproductName").val(data.productName)
            $("#saveproductId").val(data.productId)
                $("#saveregister").val(data.register)
                $("#saveregisterTime").val(data.registerTime)
                var tr = $("<tr><td id='savestoreId'>"+"3"+"</td>" +
                    "<td>"+"成品库"+"</td>" +
                    "<td >"+'D001-1'+"</td>" +
                    "<td>"+"成品区"+"</td>" +
                    "<td>"+"DK"+"</td>" +
                    "<td id='savemaxCapacityAmount'>"+"1000"+"</td>" +
                    "<td id='saveamount'>"+"100"+"</td>");
                $("#savetablea").append(tr);
            }),'json'
    }
 $("#saveaddscell").click(function () {
     alert($("#saveid_secelluler").val())
      var p={id:$("#saveid_secelluler").val(),productName:$("#saveproductName").val(),productId:$("#saveproductId").val(),minAmount:$("#saveminAmount").val(),maxAmount:$("#savemaxAmount").val()
          ,storeId:$("#savestoreId").text(),maxCapacityAmount:$("#savemaxCapacityAmount").text(),amount:$("#saveamount").text()
           ,register:$("#saveregister").val(),registerTime:$("#saveregisterTime").val(),config:$("#saveconfig").val()}
        $.post("${pageContext.request.contextPath}/addSCell.action",p,function (data) {

        },'json')

    })

</script>

</body>
</html>
